{% macro delete_list_data(msg, url, data, adom) -%}
<script type="text/javascript">
function delete_list_data(msg, url, data, adom){
    window.wxc.xcConfirm(msg, window.wxc.xcConfirm.typeEnum.warning);
    $('a.sgBtn.ok').click(function() {
        $.get(url, data, function(res){
            if (res != 'ok'){
                window.wxc.xcConfirm(res, window.wxc.xcConfirm.typeEnum.error);
                return false;
            }
            window.wxc.xcConfirm('移除成功！', window.wxc.xcConfirm.typeEnum.success);
            count_html = $(adom).parents('table:first').siblings(".row").find("a[href='javascript:;'].btn.btn-white").html();
            q_count = Number(count_html.slice(0, -1));
            if (q_count == 1){
                $(adom).parents('table:first').siblings(".row").find('#pagination').html('暂无数据');
            }else{
                var q_count = q_count-1;
                $(adom).parents('table:first').siblings(".row").find("a[href='javascript:;'].btn.btn-white").html(q_count+'条');
            }
            $(adom).parents('tr').remove();
            var t=setTimeout("$('a.sgBtn.ok').trigger('click')",900);
        });
    });
}
</script>
{%- endmacro %}

{% macro format_date() -%}
<script type="text/javascript">
function formatDate(now) {
     var year=now.getFullYear();
     var month=now.getMonth()+1;
     var date=now.getDate();
     var hour=now.getHours();
     var minute=now.getMinutes();
     var second=now.getSeconds();
     // var date = year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
     // if (second == 0){date += 0};
     if (minute <= 10){
        minute = '0'+ minute.toString();
     }
     return year+"-"+month+"-"+date+" "+hour+":"+minute;
}
</script>
{%- endmacro %}


{% macro getObjectURL() -%}
<!--把文件转换成可读URL-->
<script type="text/javascript">
function getObjectURL(file) {
    var url = null;
    if (window.createObjectURL != undefined) { // basic
        url = window.createObjectURL(file);
    } else if (window.URL != undefined) { // mozilla(firefox)
        url = window.URL.createObjectURL(file);
    } else if (window.webkitURL != undefined) { // webkit or chrome
        url = window.webkitURL.createObjectURL(file);
    }
</script>
{%- endmacro %}


{% macro add(url='') -%}
<script type="text/javascript">
$("a#add_new").click(function(){
    window.location.href ='{{ url }}';
});
</script>
{%- endmacro %}



{% macro darkTooltip(id_name='', name='') -%}
<script type="text/javascript">
$('a.'+ '{{ name }}').each(function(){
    var $a = $(this);
    var id = $a.attr('{{ id_name }}');
    $('#{{ name }}_'+id).darkTooltip({
        size:'large',
    });
});
</script>
{%- endmacro %}


{% macro Click_record(url='', click_record=0, is_refresh='ture')%}
{% if is_refresh == 'ture'%}
<script type="text/javascript">
var click_record = {{ click_record }};
$.each($("ul.nav.nav-tabs li"),function(key, row){
    if (click_record == key) {
         $(row).find("a").trigger('click');
    }
    $(row).find("a").click(function(){
        window.location.href = '{{ url }}'+'click_record='+ key;
    })
});
</script>
{% else %}
<script type="text/javascript">
var click_record = {{ click_record }};
$.each($("ul.nav.nav-tabs li"),function(key, row){
    if (click_record == key) {
        $('#click_record').val(click_record);
        $(row).find("a").trigger('click');
    }
});
</script>
{% endif %}
{%- endmacro %}
